package huaweiod.first;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 华为OD机试真题 Java 实现【猜字谜】【2022.11 Q4 新题】
 */
public class A_2023_47_WordPuzzle {

    // bdni,wooood
    // bind,wrong,wood
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        List<String> problem = Arrays.stream(in.nextLine().split(",")).collect(Collectors.toList());
        List<String> answer = Arrays.stream(in.nextLine().split(",")).collect(Collectors.toList());
        String res = "";
        for (int i = 0; i < problem.size(); i++) {
            String process1 = process(problem.get(i));
            boolean flag = false;
            for (int j = 0; j < answer.size(); j++) {
                String process2 = process(answer.get(j));
                if (process1.equals(process2)) {
                    res += answer.get(j) + ",";
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                res += "not found";
            }
        }
        System.out.println(res.substring(0, res.length() - 1));
    }

    public static String process(String s) {
        Set<Character> set = new TreeSet<>();
        for (int i = 0; i < s.length(); i++) {
            set.add(s.charAt(i));
        }
        return set.toString();
    }
}
